﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using HA.ModFlow.Domain.DomainLayer;

using System.Windows.Controls;
using HA.ModFlow.Controls;



namespace HA.ModFlow.Application
{
  public  class LPFMFViewModel:MDTVIViewModel
    {


      public LPFMFViewModel(MDTVIViewModel parent,LPFData inner)
          : base(parent, false)
      {

          this._contextMenu = new System.Windows.Controls.ContextMenu();

          MenuItem mi = new MenuItem();

          mi.Header = "属性";

          //加入临时测试用代码
          //mi.Click += new System.Windows.RoutedEventHandler(mi_Click);


          mi.Command = AppCommands.LpfEdit;

          this._contextMenu.Items.Add(mi);


          this._imageSource = VMImageSource.globaloption;


          this._isShowCheck = false;


          this._lpf = inner;


          this.LoadChildren();

      }

      //void mi_Click(object sender, System.Windows.RoutedEventArgs e)
      //{
      //    HA.ModFlow.Controls.Windows.InternalFlow.winLPFFlow win = new Controls.Windows.InternalFlow.winLPFFlow(this._lpf);
      //    if (win.ShowDialog().Value)
      //    {

      //    }


      //}



      LPFData _lpf;



      public override System.Windows.Input.ICommand DoubleClickCommand
      {
          get
          {
              return AppCommands.LpfEdit;
          }
      }


      public override string Desc
      {
          get
          {
              return "流动包LPF";
          }


      }


      protected override void LoadChildren()
      {
          //base.LoadChildren();



          //HKFlowVM hk = new HKFlowVM(this,this._lpf.Parent);

          //this.Children.Add(hk);


          //HANIFlowVM hani = new HANIFlowVM(this,this._lpf);

          //this.Children.Add(hani);

          //if (ProjectSerivce.DefaultService.Project.MfData.GridData.LayersCount > 1)
          //{
          //    VKAFlowVM vka = new VKAFlowVM(this, this._lpf);

          //    this.Children.Add(vka);
          //}

          //if (ProjectSerivce.DefaultService.Project.MfData.FlowData.IsHaveTransient)
          //{
          //    SSFlowVM ss = new SSFlowVM(this, this._lpf);

          //    this.Children.Add(ss);


          //    SYFlowVM sy = new SYFlowVM(this, this._lpf);

          //    this.Children.Add(sy);
          //}

          //if (ProjectSerivce.DefaultService.Project.MfData.FlowData.CanWet)
          //{
          //    WetDryFlowVM wetdry = new WetDryFlowVM(this, this._lpf.Parent);

          //    this.Children.Add(wetdry);
          //}
          this.ReLoadChildren();

          ProjectService.DefaultService.Project.MfData.FlowData.LpfData.LPFDataChanged+=new EventHandler(LpfData_LPFDataChanged);

      }

      void LpfData_LPFDataChanged(object sender, EventArgs e)
      {
          ReLoadChildren();
      }

      void ReLoadChildren()
      {
          this.Children.Clear();
          base.LoadChildren();



          HKFlowVM hk = new HKFlowVM(this, this._lpf.Parent);

          this.Children.Add(hk);


          HANIFlowVM hani = new HANIFlowVM(this, this._lpf);

          this.Children.Add(hani);

          if (ProjectService.DefaultService.Project.MfData.GridData.LayersCount > 1)
          {
              VKAFlowVM vka = new VKAFlowVM(this, this._lpf);

              this.Children.Add(vka);
          }

          if (ProjectService.DefaultService.Project.MfData.FlowData.IsHaveTransient)
          {
              SSFlowVM ss = new SSFlowVM(this, this._lpf);

              this.Children.Add(ss);


              SYFlowVM sy = new SYFlowVM(this, this._lpf);

              this.Children.Add(sy);
          }

          if (ProjectService.DefaultService.Project.MfData.FlowData.CanWet)
          {
              WetDryFlowVM wetdry = new WetDryFlowVM(this, this._lpf.Parent);

              this.Children.Add(wetdry);
          }

      }

      protected override void OnSelectedChanged()
      {
          if (this.IsSelected)
          {

              UIModule.DefaultModule.RibbonV2ViewModel.ViewOpViewModel.ToolVM.CurrentTool = APPTOOLMODE.GRID3D;

          }
      }


    }
}
